Namespacing everything to /UVa.
[andmenj-acm.git] / UVa / 100 - The 3n + 1 problem / 100.cpp
blobdd47412b8d7e0140001b395735f83ed1c651e981
1 using namespace std;
2 #include <algorithm>
3 #include <iostream>
4 #include <iterator>
5 #include <numeric>
6 #include <sstream>
7 #include <fstream>
8 #include <cassert>
9 #include <climits>
10 #include <cstdlib>
11 #include <cstring>
12 #include <string>
13 #include <cstdio>
14 #include <vector>
15 #include <cmath>
16 #include <queue>
17 #include <deque>
18 #include <stack>
19 #include <list>
20 #include <map>
21 #include <set>
23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
27 int f(unsigned int n) {
28 int ans = 0;
29 while (n > 1) {
30 ans++;
31 if (n % 2 == 0) n = n / 2;
32 else n = 3 * n + 1;
34 return ans + 1;
37 int main(){
38 unsigned int a, b;
39 while (cin >> a >> b) {
40 int ans = -1;
41 for (int i = min(a, b); i <= max(a, b); ++i) {
42 ans = max(ans, f(i));
44 printf("%d %d %d\n", a, b, ans);
46 return 0;